import os
import yaml
from movie import settings
from utils.response import wrap_json_response, ReturnCode
from django.http import JsonResponse


def _init_app_data():
    data_file = os.path.join(settings.BASE_DIR, "app.yml")
    with open(data_file, "r", encoding="utf-8") as f:
        apps = yaml.load(f, Loader=yaml.FullLoader)
    return apps


def get_menu(request):
    app_data = _init_app_data()
    published_data = app_data.get("published")
    response = wrap_json_response(data=published_data, code=ReturnCode.SUCCESS)
    return JsonResponse(data=response, safe=False, status=200)


if __name__ == "__main__":
    menu = get_menu()


    pass